Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

194
Vistas
jsPDF jQuery.Deferred exception: r[o] is undefined

I am trying to use jsPDF to download a PDF version of my website. I am getting this error jQuery.Deferred exception: r[o] is undefined. I think it has to do with "var source = $("#content")[0]" in the body somehow being undefined, but I'm not sure if this is the only problem.

Necessary Imports (in head):

    <!-- jQuery library -->
  <script src="static/js/jquery.min.js"></script>

  <!-- jsPDF library -->
  <script src="static/js/jsPDF-1.3.2/dist/jspdf.min.js"></script>

/* Bootstrap at end of body */
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" crossorigin="anonymous"></script>

HTML

<div class="container-fluid" id="content">
    <div class="row">
        <h1>UH ENERGY</h1>
    </div>
    <div class="row">
        <a href="#" id="downloadPDF" >Download PDF</a>
    </div>
    <!--CHART 1-->
    <div class="row">
        <div class="col-md-6 col-sm-12 col-xs-12">
            <canvas id="myChart" class="bar-chart"></canvas>
    <!-- Continued -->

function in main.py

$( document ).ready(function() {
    var doc = new jsPDF(); 
    var specialElementHandlers = {
        "#bypassme": function (element, renderer) {
            return true
        }
    }; 
    var margins = {
        top: 80,
        bottom: 60,
        left: 40,
        width: 522
    }; 
    var source = $("#content")[0];
    doc.fromHTML(
        source.innerHTML,
        margins.left, 
        margins.top, 
        {
            "width": margins.width,
            "elementHandlers": specialElementHandlers
        }, 
        function (dispose) { 
            doc.save("ICEV-EV.pdf"); 
        }, 
        margins
    ); 
    });
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda